﻿var dialog	= window.parent ;
var oEditor = dialog.InnerDialogLoaded() ;

var FCK			= oEditor.FCK ;
var FCKLang		= oEditor.FCKLang ;
var FCKConfig	= oEditor.FCKConfig ;
var FCKRegexLib	= oEditor.FCKRegexLib ;
var FCKTools	= oEditor.FCKTools ;

//#### Dialog Tabs

// Set the dialog tabs.
dialog.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ;

// Function called when a dialog tag is selected.
function OnDialogTabChange( tabCode )
{
	ShowE('divInfo'		, ( tabCode == 'Info' ) ) ;
	dialog.SetAutoSize( true ) ;
}

//#### Initialization Code
window.onload = function()
{
	// Activate the "OK" button.
	dialog.SetOkButton( true ) ;
}

//#### Called while the user types the URL.
function OnUrlChange()
{
}

//#### The OK button was hit.
function Ok()
{
	var sUri, sInnerHtml ;
	oEditor.FCKUndo.SaveUndoStep() ;

	sUri = document.getElementById('txtUrl').value ;

    FCK.InsertHtml('<a href="'+sUri+'">'+sUri+'</a>');

	return true ;
}

function BrowseServer()
{
	OpenFileBrowser( '../../../../FileManager.aspx?popup=1', oEditor.FCKConfig.ScreenWidth * 0.8, oEditor.FCKConfig.ScreenHeight * 0.7 ) ;
}

function OpenFileBrowser( url, width, height )
{
	var iLeft = ( oEditor.FCKConfig.ScreenWidth  - width ) / 2 ;
	var iTop  = ( oEditor.FCKConfig.ScreenHeight - height ) / 2 ;

	var sOptions = "toolbar=no,status=yes,resizable=yes,dependent=yes,scrollbars=yes" ;
	sOptions += ",width=" + width ;
	sOptions += ",height=" + height ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	window.open( url, 'FCKBrowseWindow', sOptions ) ;
}